﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using NUnit.Framework;

namespace Legend.Web.QueryString.Tests
{
    [TestFixture]
    public class DataContractParameterAccessorTests
    {
        [SetUp]
        public void SetUp()
        {
            
        }

        [Test, ExpectedException(typeof(ArgumentNullException))]
        public virtual void Constructor_throws_when_value_is_null()
        {
            new DataContractParameterAccessor(null);
        }

        [Test]
        public virtual void GetAllParametersAndValues_gets_value_of_tagged_property()
        {
            var contract = new FooContract() {Foo = 10};
            var accessor = new DataContractParameterAccessor(contract);

            Assert.AreEqual("10", accessor.GetAllParametersAndValues()["Foo"]);
        }

        [DataContract]
        private class FooContract
        {
            [DataMember]
            public int Foo { get; set; } 
        }
    }
}
